package com.ruitu.mall_98_2.mvp.presenter;

import com.beanu.arad.utils.ToastUtils;
import com.ruitu.mall_98_2.mvp.contract.RelevanceTelContract;
import com.ruitu.router_module.bean.User;
import com.ruitu.router_module.bean.api.BaseResult;
import com.ruitu.router_module.bean.api.SubscriberImpl;

public class RelevanceTelPresenter extends RelevanceTelContract.Presenter {
    @Override
    public void registerForQqOrWx(String openId, String type, String phone, String pwd, String code,String otherName) {
        mModel.registerForQqOrWx(openId, type, phone, pwd, code,otherName)
                .subscribe(new SubscriberImpl<BaseResult<User>>() {
                    @Override
                    public void onError(Throwable e) {
                        mView.hideProgress();
                        ToastUtils.showShort("绑定异常");
                    }

                    @Override
                    public void onNext(BaseResult<User> userBaseResult) {
                        mView.hideProgress();
                        if (userBaseResult.isSuccess()) {
                            mView.registerAccounts(userBaseResult.getData());
                        } else {
                            ToastUtils.showShort(userBaseResult.getMsg());
                        }
                    }
                });
    }
}
